/**
 * Copyright (c) 2010 by Kevin Bierhoff.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *    1. Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *    2. Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *    3. Neither the names of the authors nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
package com.googlecode.syper.javasyp.config;

import org.eclipse.jface.preference.IPreferenceStore;

import com.googlecode.syper.javasyp.Activator;

/**
 * @author kevin
 * @since Mar 1, 2010
 */
public class JavaSypPreferences {

	public static final String SMT_SOLVER_Z3 = "Z3";

	private static JavaSypPreferences instance;

	public synchronized static JavaSypPreferences getInstance() {
		if (instance == null)
			instance = new JavaSypPreferences();
		return instance;
	}

	private JavaSypPreferences() {
	}

	/** Path to the executable of the given solver */
	public String getExecutable(String solver) {
		return getPreferences().getString(getExecutablePreferenceKey(solver));
	}

	static String getExecutablePreferenceKey(String solver) {
		return "executable" + solver;
	}

	/** Timeout for the given solver so we don't wait forever */
	public int getTimeoutSeconds(String solver) {
		// use common timeout for all solvers
		return getPreferences().getInt(getTimeoutPreferenceKey());
	}

	static String getTimeoutPreferenceKey() {
		return "timeoutSeconds";
	}

	/** If true counterexamples will be printed for unprovable assertions */
	public boolean isCounterexamplesRequested() {
		return getPreferences().getBoolean(getShowCounterexamplePreferenceKey());
	}

	static String getShowCounterexamplePreferenceKey() {
		return "showCounterexample";
	}

	/** If true we'll try to prove "assume" statements before assuming them */
	public boolean isProveAssumptions() {
		return getPreferences().getBoolean(getProveAssumptionsPreferenceKey());
	}

	static String getProveAssumptionsPreferenceKey() {
		return "proveAssumptions";
	}

	static IPreferenceStore getPreferences() {
		return Activator.getDefault().getPreferenceStore();
	}
}
